package com.example.wlzz.repository.mapper.admin;


import com.example.wlzz.dto.admin.RoleDTO;
import com.example.wlzz.entity.admin.Permission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleMapper {
    @Select("select id,role_name," +
            "(select nick_name from user_info where user_id = (select user_id from user_ where phone =  #{phone} ))nick_name"+
            " from role where id = " +
            "(select role_id from user_with_role where userid = " +
            "(select user_id from user_ where phone = #{phone}));")
    RoleDTO getRoleName(@Param("phone") String phone);
    @Select("select id,permission_name permissionName,url,status,create_time createTime,permission_desc permissionDesc" +
            " from permission" +
            " where id in " +
            "(select permission_id from role_with_permission where role_id = #{role_id})")
    List<Permission>  findPermissionByRoleId(@Param("role_id") int  roleId);

}
